//
//  HomeNewsDetailViewController.m
//  SoccerHoneypot
//
//  Created by Wii on 16/6/21.
//  Copyright © 2016年 Wii. All rights reserved.
//

#import "WiiNewsDetailViewController.h"

@interface WiiNewsDetailViewController ()

@property (nonatomic , strong) WKWebView *wkWeb;
@end

@implementation WiiNewsDetailViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    [self makeRightButton];
    [self initUserInterface];
//    DLog(@"%@",self.model);
}

- (void)makeRightButton {
    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
    rightButton.frame = CGRectMake(0, 0, 80, 20);
    rightButton.titleLabel.font = [UIFont systemFontOfSize:12];
    rightButton.titleLabel.textAlignment = NSTextAlignmentRight;
    rightButton.layer.borderWidth = 1.0;
    rightButton.layer.borderColor = [[UIColor whiteColor]CGColor];
    [rightButton setTitle:[NSString stringWithFormat:@"%ld条评论",self.model.comments_total] forState:UIControlStateNormal];
    [rightButton addTarget:self action:@selector(rightButtonHandleEvent:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
}

- (void)initUserInterface {
    
    [self.wkWeb loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.model.url]]];
    [self.view addSubview:self.wkWeb];
}

#pragma mark - RightButton HandleEvent

- (void)rightButtonHandleEvent:(UIButton *)sender {
//    DLog(@"hehe");
}

#pragma mark - LazzyLoad
- (WKWebView *)wkWeb {
    if (!_wkWeb) {
        _wkWeb = [[WKWebView alloc]initWithFrame:self.view.bounds];
        _wkWeb.allowsBackForwardNavigationGestures = YES;
        
    }
    return _wkWeb;
}

@end
